<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #div {
            width: 200px;
            height: 200px;
            background: black;
            color: #fff;
        }
    </style>
</head>

<body>
    <p>
        属性名: <input type="text" id="in1">
    </p>
    <p>
        属性值: <input type="text" id="in2">
    </p>
    <p>
        <button id="btn">确定</button>
        <button>重置</button>
    </p>
    <div id="div">
        张茂森
    </div>
</body>

</html>
<script>
    let inp1 = document.getElementById('in1');
    let inp2 = document.getElementById('in2');
    let bt = document.getElementById('btn')
    bt.onclick = function () {
        var name1 = ''
        var name2 = ''
        inp1.onblur = function () {
            this.name1 = this.value
        }
        inp2.onblur = function () {
            this.name2 = this.value
        }
    }



</script>